package com.yuyou.train.user.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yuyou.train.service.api.user.entity.UserRemind;
import com.yuyou.train.user.mapper.UserRemindMapper;
import com.yuyou.train.user.service.IUserRemindService;
import com.yuyou.train.util.bean.Pagination;
import com.yuyou.train.util.bean.ResBoolSimpleInfo;
import com.yuyou.train.util.enums.user.UserRemindEnums;
import com.yuyou.train.util.tool.Sequence;
import com.yuyou.train.util.tool.UUIDUtil;

@Service
public class UserRemindServiceImpl implements IUserRemindService{

	@Autowired
	private UserRemindMapper userRemindMapper;
	
	@Override
	public int deleteByPrimaryKey(String id) {
		return userRemindMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(UserRemind record) {
		record.setId(Sequence.getSequence().getNextId());
		record.setCreateTime(new Date());
		return userRemindMapper.insert(record);
	}

	@Override
	public UserRemind selectByPrimaryKey(String id) {
		return userRemindMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(UserRemind record) {
		record.setUpdateTime(new Date());
		return userRemindMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public List<UserRemind> selectByReceUserId(String receUserId) {
		return userRemindMapper.selectByReceUserId(receUserId);
	}

	@Override
	public int findUserRemindPageCount(Pagination<UserRemind> p) {
		return userRemindMapper.findUserRemindPageCount(p);
	}

	@Override
	public List<UserRemind> findUserRemindPage(Pagination<UserRemind> p) {
		return userRemindMapper.findUserRemindPage(p);
	}

	@Override
	public ResBoolSimpleInfo<String> addRemind(UserRemind userRemind) {		
		this.insert(userRemind);
		return ResBoolSimpleInfo.getSuccessInfo();
	}

	@Override
	public ResBoolSimpleInfo<String> finishRemind(String id) {
		UserRemind up=new UserRemind();
		up.setId(id);
		up.setStatus(UserRemindEnums.status.finish.getValue());
		this.updateByPrimaryKeySelective(up);
		return ResBoolSimpleInfo.getSuccessInfo();
	}


}